//
//  HMStatus.swift
//  weibo
//
//  Created by LCH on 16/3/10.
//  Copyright © 2016年 lch. All rights reserved.
//

import UIKit

class HMStatus: NSObject {
    
    var id : Int64 = 0

    // 微博内容
    var text: String?
    // 当前微博的创建时间
   var created_at: String?
    // 微博来源
    var source: String?
    // 当前发送此条微博的用户信息
    var user: HMUser?
    
    // 转发数量
    var reposts_count: Int = 0
    // 评论数量
    var comments_count: Int = 0
    // 点赞数量
    var attitudes_count: Int = 0
    
    // 转发微博
    var retweeted_status: HMStatus?
    
    //原创微博配图
    var pic_urls:[HMStatusPictureInfo]?

    
    
    override func setValue(value: AnyObject?, forKey key: String) {
        
        if key == "user" {
        
            guard let v = value as? [String : AnyObject] else {
            
              return
            
            }
            user = HMUser(dict:v)
        }else if key == "retweeted_status" {
        
            guard let v = value as? [String:AnyObject] else{
            
              return
            }
            retweeted_status = HMStatus(dict: v)
//            print("v------\(v)")
        
        }else if key == "pic_urls"{
        
            guard let values = value as? [[String : AnyObject]] else {
            
             return
            
            }
            var tempArray = [HMStatusPictureInfo]()
            for v in values {
            
                let picture = HMStatusPictureInfo(dict: v)
               tempArray.append(picture)
            
            }
            self.pic_urls = tempArray
          
        }
        else {
        
          super.setValue(value, forKey: key)
        
        }
    }
    
    
    
    
    init(dict:[String:AnyObject]) {
        
        super.init()
        setValuesForKeysWithDictionary(dict)
    }
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {
        
    }
    
}
